package com.qihoo.finance.lcs;

import com.google.common.base.Splitter;
import org.apache.commons.io.FileUtils;

import java.io.File;
import java.io.IOException;
import java.util.List;
import java.util.Map;

public class Main {

    public static void main(String[] args) throws IOException {
        String database = "lcs";
        String key = "c_lcs";
        String tables = "ln_loan,ln_plan,ln_loan_stats";
        String baseResultPath = "canal-adapter-yml-tool/target/ymls/";
        List<String> tableList = Splitter.on(",").trimResults().splitToList(tables);

        Generator generator = new Generator(database, key, tableList);
        Map<String, String> resultMap = generator.generate();

        for (Map.Entry<String, String> entry : resultMap.entrySet()) {
            FileUtils.writeStringToFile(new File(baseResultPath + entry.getKey() + ".yml"), entry.getValue(), "utf-8");
        }

    }

}
